#ifndef _INCLUDED_RPC_H_
#define _INCLUDED_RPC_H_
#include <vector>

//Functions for remote procedure call

struct rpc_message{
	
	unsigned int rpc_id;
	const char* arg_str;
	size_t arg_str_length;

	std::vector<char> pack();
	explicit rpc_message(const std::vector<char>& serialized_str);
};




#include "rpc_inl.h"


//rpc function declare
template<typename F,int Idx>
struct rpc_function_info_t
{
	enum{index = Idx};
	typedef F function_type;
	//typedef typename rpc_func_param_type_list<F>::arg_tuple arg_tuple;
};

//code generation
template<typename RpcT,typename Handler,typename ArgT0>
void send_rpc(Handler handler, const ArgT0& arg0)
{
	std::vector<char> mem;
	serialize(RpcT::index,&mem);
	serialize(arg0,&mem);
	handler(boost::system::error_code(),mem);
}

//
template<typename RpcT,typename ConnPtr,typename ArgT0,typename ArgT1>
void send_rpc(ConnPtr conn, const ArgT0& arg0,const ArgT1& arg1)
{
	//todo n arguments
	assert(false);
}


namespace c2s{
	typedef rpc_function_info_t<void(const serializable_sequence<std::string,2>& ),0> grep_rpc_t;
}
namespace s2c{
	typedef rpc_function_info_t<void(const serializable_sequence<std::string,2>& ),0> grep_result_rpc_t;
}

#endif